package com.guli.order.web;

import com.guli.order.config.AliPayTemplate;
import com.guli.order.service.OrderService;
import com.guli.order.vo.PayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author zzb
 * @Date 2024/4/22 16:53
 * @Version 1.0
 */
@RestController
public class PayWebController {
    @Autowired
    private AliPayTemplate aliPayTemplate;
    @Autowired
    private OrderService orderService;

    /**
     * 订单支付
     * @param orderSn
     * @return
     */
    @GetMapping(value = "/payOrder", produces = "text/html")
    public String payOrder(@RequestParam("orderSn") String orderSn) {
        PayVo payVo = orderService.getOrderPay(orderSn);
        return aliPayTemplate.pay(payVo);
    }
}
